*Summary-----------------------------------------------------------------------

*Parameters--------------------------------------------------------------------
local exch=2288 //Exchange rate TSH per USD

*get invoice value and area for 225 sampled properties--------------------------
use "${sdir}/Sample_owners.dta", clear
keep ShinaID plot_code full_cost invoice lot_area_inv sub_sample_wt
rename (ShinaID plot_code) (shina_id plot_id)
save "temp/owner_sample_full_cost.dta", replace

*get sample of 146 owners-------------------------------------------------------
use "${sdir}/Owners_cln.dta", clear

merge 1:1 shina_id plot_id using "temp/owner_sample_full_cost.dta", nogen
keep if owner_observed==1

sum s9_q_1 

//>>some descriptives of heterogeneity in WTP. Focus on heterogeniety by the three main private benefits (expropriation, loans, transfer). Also think of some heterogeneity by gender, age, size of property, income, etc)

*adjust variables
gen WTP=s9_q_1/`exch'
gen female=(s1_q_1_1==1 &s0_q_1==1) //sole female owner
gen joint=(s0_q_1==2) //joint owned
gen age40_60=(s1_q_2_1==2 | s1_q_2_1==3)
gen over60=(s1_q_2_1==4)
gen med_income=(s1_q_6_1>1 & s1_q_6_1<5)
gen high_income=(s1_q_6_1>=5)
gen med_edu=(s1_q_5_1>2&s1_q_5_1<5) //primary or less
gen hi_edu=(s1_q_5_1>=5) //more than secondary

*ranked benefits
gen top_protect_exp=(s5_q_2_1==1)
gen nbid_protect_exp=cond(missing(s5_q_3_1)==0,s5_q_3_1, s9_q_1)
gen top_boundary_disp=(s5_q_2_2==1)
gen nbid_boundary_disp=cond(missing(s5_q_3_2)==0,s5_q_3_2, s9_q_1)
gen top_heirs=(s5_q_2_3==1)
gen nbid_heirs=cond(missing(s5_q_3_3)==0,s5_q_3_3, s9_q_1)
gen top_loans=(s5_q_2_7==1)
gen nbid_loans=cond(missing(s5_q_3_7)==0,s5_q_3_7, s9_q_1)


*ranked costs
gen top_land_rent=(s6_q_2_1==1)
gen nbid_land_rent=cond(missing(s6_q_3_1)==0,s6_q_3_1, s9_q_1)
gen top_plan_reg=(s6_q_2_2==1)
gen nbid_plan_reg=cond(missing(s6_q_3_2)==0,s6_q_3_2, s9_q_1)
gen top_time_effort=(s6_q_2_3==1)
gen nbid_time_effort=cond(missing(s6_q_3_3)==0,s6_q_3_3, s9_q_1)
gen top_bribes=(s6_q_2_4==1)
gen nbid_bribes=cond(missing(s6_q_3_4)==0,s6_q_3_4, s9_q_1)


*labels
label var lot_area_inv 		"Lot Size (sq-m)"
label var female 			"Sole Female"
label var joint				"Joint Owners"
label var age40_60 			"Age 40-60"
label var over60 			"Age 60+"
label var med_income 		"Middle Income"
label var high_income 		"High Income"
label var med_edu 			"Secondary Education"
label var hi_edu 			"Higher Education"

*What are the top benefits and costs to title deeds?
foreach v of varlist top*{
    tab `v'
}
sum nbid*

*credit constraints
tab s7_q_1_1
sum s7_q_1_2 if s7_q_1_1==1
sum s2_q_3 if s7_q_1_1==1


*regressions
eststo: reg WTP female joint, vce(robust)
eststo: reg WTP age40_60 over60, vce(robust)
eststo: reg WTP med_income high_income, vce(robust)
eststo: reg WTP med_edu hi_edu, vce(robust)
eststo: reg WTP lot_area_inv, vce(robust)
eststo: reg WTP female joint age40_60 over60 med_income high_income med_edu hi_edu lot_area_inv, vce(robust)

local note ///
	This table presents coefficients from regressions of willingness-to-pay on plot and plot owner characteristics. Each observation is a plot. The dependent variable is always the willingness-to-pay in USD. The category middle income refers to households with monthly income 44 and 131 USD. The category high income refers to households with monthly income over 131 USD. Robust standard errors in parentheses. \sym{*}\(p<0.10\),	\sym{**}\(p<0.05\), \sym{***}\(p<0.01\).
	
esttab * using "tables/wtp_heterogeneity.tex", ///
	se r2 label nocons replace nomtitles ///
	star(* 0.10 ** 0.05 *** 0.01) ///
	prehead("\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} {\centering\begin{tabular}{l*{6}{c}} \hline\hline") ///
	postfoot("\hline\hline \end{tabular}\par\medskip}{\footnotesize {\it Note: }`note'}")
estimates clear


*END--------
clear
